package com.amsp.oa.oademo.controller;

import com.amsp.oa.oademo.service.TrainingSignInService;
import com.amsp.oa.oademo.vo.TrainingSignInVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "培训签到管理")
@RestController
@RequestMapping("/api/training-sign-in")
public class TrainingSignInController {

    @Resource
    private TrainingSignInService trainingSignInService;

    @ApiOperation("保存培训签到信息")
    @PostMapping("/save")
    public void save(@RequestBody TrainingSignInVO trainingSignInVO) {
        trainingSignInService.saveTrainingSignIn(trainingSignInVO);
    }

    @ApiOperation("获取培训签到详情")
    @GetMapping("/{id}")
    public TrainingSignInVO getById(@PathVariable Long id) {
        return trainingSignInService.getTrainingSignInById(id);
    }

    @ApiOperation("获取培训签到列表")
    @GetMapping("/list")
    public IPage<TrainingSignInVO> list(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size,
            @RequestParam(required = false) String keyword) {
        return trainingSignInService.getTrainingSignInList(new Page<>(current, size), keyword);
    }

    @ApiOperation("删除培训签到")
    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        trainingSignInService.deleteTrainingSignIn(id);
    }
}